package collect.taobao.action;

import java.util.List;

import javax.servlet.ServletContext;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import collect.taobao.bean.ClassificationDirectoryRelationBean;
import collect.taobao.service.ClassificationDirectoryRelationService;
import collect.taobao.util.SuperAction;
import collect.taobao.util.charset.CHARSET_CODE;
import collect.taobao.util.string.StringUtil;

public class ClassificationDirectoryRelationAction  extends SuperAction{

	public ClassificationDirectoryRelationAction() {
		super();
	}

	public String queryListByClassification(){
			String classification =  StringUtil.getUrlChineseString(this.getReq(), "CLASSIFICATION");
			ServletContext servletContext = this.getReq().getSession().getServletContext(); 
			ApplicationContext ctx=WebApplicationContextUtils.getWebApplicationContext(servletContext); 
			ClassificationDirectoryRelationService service = (ClassificationDirectoryRelationService)ctx.getBean("classificationDirectoryRelationServerInterface");
			List ls = service.queryListByClassification(classification);
			
//			ClassificationDirectoryRelationBean tmp = (ClassificationDirectoryRelationBean)ls.get(0);
			
			for(int i = 0;i<ls.size();i++){
				ClassificationDirectoryRelationBean tmp = (ClassificationDirectoryRelationBean)ls.get(i);
				System.out.println("----->"+tmp.getDirectory());
			}
//			String directory = tmp.getDirectory();
//			File file  = new File(directory);
//			if(file.exists()&&file.isDirectory()){
//				for(int i=0;i<file.length();i++){
//					System.out.println(file.getName());
//				}
//			}
			return "success";
	}

}
